
// 元对象，支持类中缺失成员或方法

class Example{
    static void main(String[] args){
        Student st = new Student()
        st.name = "jackie";
        st.id = 1;

        println(st.id)
        println(st.name)

        println st.display()
    }
}

class Student implements GroovyInterceptable {
    protected dynamicProps = [:]

    // 缺失属性setter
    void setProperty(String pName, val){
        dynamicProps[pName] = val
    }

    // 缺失属性getter
    def getProperty(String pName){
        dynamicProps[pName]
    }

    // 缺失的方法
    def invokeMethod(String name, Object args){
        return "called invokeMethod $name($args)"
    }
}